<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>文本框</title>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="generator" content="www.leipi.org"/>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
    <!--[if lte IE 6]>
    <link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap-ie6.css">
    <![endif]-->
    <!--[if lte IE 7]>
    <link rel="stylesheet" type="text/css" href="bootstrap/css/ie.css">
    <![endif]-->
    <link rel="stylesheet" href="leipi.style.css">
    <script type="text/javascript" src="../dialogs/internal.js"></script>
</head>
<body>
<div class="content">
    <table class="table table-bordered table-striped table-hover">
        <tr>
            <th><span>控件字段&nbsp;</span><span class="label label-important">*</span></th>
            <th><span style="display:none"><span>字体大小</span><input id="orgfontsize" type="text" value="" class="input-small span1" placeholder="auto"/>
          px </span><span>控件名称&nbsp;</span><span class="label label-important">*</span></th>
        </tr>
        <tr>
            <td><input id="orgname" type="text" placeholder="必填项"/></td>
            <td><input type="text" id="orgtitle" placeholder="必填项"></td>
        </tr>
        <tr>
            <th>长度/大小</th>
            <th>必填项</th>
        </tr>
        <tr>
            <td>
                <select id="minT" name="minT" style="width:60px">
                    <option value="d=">>=</option>
                    <option value="d">></option>
                    <option value="=">=</option>
                </select>
                <input id="minV" name="minV" type="text" style="width:40px">
                <select id="maxT" name="maxT" style="width:60px">
                    <option value="x="><=</option>
                    <option value="x"><</option>
                </select>
                <input id="maxV" name="maxV" type="text" style="width:40px">

                <select id="orgalign" style="display:none">
                    <option value="left">左对齐</option>
                    <option value="center">居中对齐</option>
                    <option value="right">右对齐</option>
                </select>
            </td>
            <td>
                <input id="canNull" name="canNull" type="checkbox" value="0"/>
            </td>
        </tr>
        <tr style="display:none">
            <th><span>数据类型</span></th>
            <th>&nbsp;</th>
        </tr>
        <tr style="display:none">
            <td>
                <select id="orgtype">
                    <option value="0">字符串型</option>
                    <option value="1">文本型</option>
                    <option value="2">整型</option>
                    <option value="3">长整型</option>
                    <option value="4">布尔型</option>
                    <option value="5">浮点型</option>
                    <option value="6">双精度型</option>
                    <!--<option value="7">日期型</option>
                    <option value="8">日期时间型</option>
                    -->
                    <option value="9">价格型</option>
                </select>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <th><span>输入框样式</span></th>
            <th><span style="display: none">增强</span></th>
        </tr>
        <tr>
            <td>
                宽 <input id="orgwidth" type="text" value="300" class="input-small span1" placeholder="auto"/> px
                &nbsp;&nbsp;
                高 <input id="orgheight" type="text" value="80" class="input-small span1" placeholder="auto"/> px
            </td>
            <td><label class="checkbox" style="display: none"><input id="orgrich" type="checkbox"/> 富文本形式 </label></td>
        </tr>
        <tr>
            <th><span>只读</span></th>
            <th><span>只读类型</span></th>
        </tr>
        <tr>
            <td>
                <input id="isReadOnly" name="isReadOnly" type="checkbox" value="1"/>
            </td>
            <td>
                <select id="readOnlyType">
                    <option value="">不限</option>
                    <option value="0">仅添加时</option>
                    <option value="1">仅编辑时</option>
                    <option value="2">仅编辑引用记录时</option>
                </select>
                <br/>仅编辑引用记录时适用于”嵌套表格2“宏控件选取的记录
            </td>
        </tr>
        <tr>
            <th><span>提示</span></th>
            <th><span></span></th>
        </tr>
        <tr>
            <td>
                <textarea id="tip" name="tip" style="width:250px; height:100px"></textarea>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <label for="orgvalue">默认值</label>
                <textarea class="input-block-level" rows="3" id="orgvalue" placeholder="多行文本框默认值..."></textarea>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    var oNode = null, thePlugins = 'textarea';
    window.onload = function () {
        if (UE.plugins[thePlugins].editdom) {
            oNode = UE.plugins[thePlugins].editdom;
            var gName = oNode.getAttribute('name').replace(/&quot;/g, "\"");
            var gValue = oNode.getAttribute('value').replace(/&quot;/g, "\""), gTitle = oNode.getAttribute('title').replace(/&quot;/g, "\""), gFontSize = oNode.getAttribute('orgfontsize'), gWidth = oNode.getAttribute('orgwidth'), gHeight = oNode.getAttribute('orgheight'), gRich = oNode.getAttribute('orgrich');

            gValue = gValue == null ? '' : gValue;
            gTitle = gTitle == null ? '' : gTitle;

            var gType = oNode.getAttribute('fieldType');
            var gCanNull = oNode.getAttribute("canNull");
            var gMinT = oNode.getAttribute("minT");
            var gMinV = oNode.getAttribute("minV");
            var gMaxT = oNode.getAttribute("maxT");
            var gMaxV = oNode.getAttribute("maxV");
            var gTip = oNode.getAttribute("tip");
            if (gTip == null) {
                gTip = '';
            }

            $G('orgvalue').value = gValue;
            $G('orgname').value = gName;
            $G('orgtitle').value = gTitle;
            if (gRich == '1') {
                $G('orgrich').checked = true;
            }
            $G('orgfontsize').value = gFontSize;
            $G('orgwidth').value = gWidth;
            $G('orgheight').value = gHeight;
            $G('orgtype').value = gType;
            $G('orgname').setAttribute("readonly", true);
            $G('orgtype').setAttribute("disabled", true);

            if (gCanNull == 0) {
                $G('canNull').checked = true;
            } else {
                $G('canNull').checked = false;
            }

            var isReadOnly = oNode.getAttribute("readonly");
            if (isReadOnly != null) {
                $G('isReadOnly').checked = true;
            } else {
                $G('isReadOnly').checked = false;
            }

            var gReadOnlyType = oNode.getAttribute("readOnlyType");
            if (gReadOnlyType == null) {
                gReadOnlyType = '';
            }
            $G('readOnlyType').value = gReadOnlyType;

            if (gMinT) {
                $G('minT').value = gMinT;
                $G('minV').value = gMinV;
                $G('maxT').value = gMaxT;
                $G('maxV').value = gMaxV;
            }
            $G('tip').value = gTip;
        }
    }
    dialog.oncancel = function () {
        if (UE.plugins[thePlugins].editdom) {
            delete UE.plugins[thePlugins].editdom;
        }
    };
    dialog.onok = function () {
        var gName = $G('orgname').value.replace(/\"/g, "&quot;");
        if (gName == '') {
            alert('请输入控件字段');
            return false;
        }
        var gTitle = $G('orgtitle').value.replace(/\"/g, "&quot;");
        if (gTitle == '') {
            alert('请输入控件名称');
            return false;
        }

        var gValue = $G('orgvalue').value.replace(/\"/g, "&quot;"), gFontSize = $G('orgfontsize').value, gWidth = $G('orgwidth').value, gHeight = $G('orgheight').value;

        var gType = $G('orgtype').value;
        var gCanNull = $G('canNull').checked ? 0 : 1;
        var gMinT = $G('minT').value;
        var gMinV = $G('minV').value;
        var gMaxT = $G('maxT').value;
        var gMaxV = $G('maxV').value;
        var gTip = $G('tip').value;
        var gReadOnlyType = $G('readOnlyType').value;

        if (!oNode) {
            try {
                var html = '<textarea ';
                html += ' name = "' + gName + '"';
                html += ' title = "' + gTitle + '"';
                html += ' cwsPlugins = "' + thePlugins + '"';
                html += ' value = "' + gValue + '"';
                if ($G('orgrich').checked) {
                    html += ' orgrich = "1"';
                } else {
                    html += ' orgrich = "0"';
                }
                if (gFontSize != '') {
                    html += ' orgfontsize = "' + gFontSize + '"';
                } else {
                    html += ' orgfontsize = ""';
                }
                if (gWidth != '') {
                    html += ' orgwidth = "' + gWidth + '"';
                } else {
                    html += ' orgwidth = ""';
                }
                if (gHeight != '') {
                    html += ' orgheight = "' + gHeight + '"';
                } else {
                    html += ' orgheight = ""';
                }

                html += ' style = "';
                if (gFontSize != '') {
                    html += 'font-size:' + gFontSize + 'px;';
                }
                if (gWidth != '') {
                    html += 'width:' + gWidth + 'px;';
                }
                if (gHeight != '') {
                    html += 'height:' + gHeight + 'px;';
                }

                html += '"';

                if (gType != '') {
                    html += ' fieldType="' + gType + '"';
                }

                html += ' canNull="' + gCanNull + '"';
                html += ' minT="' + gMinT + '"';
                html += ' minV="' + gMinV + '"';
                html += ' maxT="' + gMaxT + '"';
                html += ' maxV="' + gMaxV + '"';

                if ($G('isReadOnly').checked) {
                    html += ' readonly="readonly" ';
                }
                html += ' readOnlyType="' + gReadOnlyType + '" ';

                html += ' tip="' + gTip + '"';

                html += ">";
                html += gValue + '</textarea>';

                editor.execCommand('insertHtml', html);
            } catch (e) {
                try {
                    editor.execCommand('error');
                } catch (e) {
                    alert('控件异常，请到 [雷劈网] 反馈或寻求帮助！');
                }
                return false;
            }
        } else {
            oNode.setAttribute('title', gTitle);
            oNode.setAttribute('value', gValue);
            oNode.innerHTML = gValue;
            if ($G('orgrich').checked) {
                oNode.setAttribute('orgrich', 1);
            } else {
                oNode.setAttribute('orgrich', 0);
            }

            if (gFontSize != '') {
                oNode.style.fontSize = gFontSize + 'px';
                oNode.setAttribute('orgfontsize', gFontSize);
            } else {
                oNode.setAttribute('orgfontsize', '');
            }
            if (gWidth != '') {
                oNode.style.width = gWidth + 'px';
                oNode.setAttribute('orgwidth', gWidth);
            } else {
                oNode.setAttribute('orgwidth', '');
            }
            if (gHeight != '') {
                oNode.style.height = gHeight + 'px';
                oNode.setAttribute('orgheight', gHeight);
            } else {
                oNode.setAttribute('orgheight', '');
            }

            /*
            if( gType != '' ) {
                oNode.setAttribute('fieldType',gType );
            }
            */

            oNode.setAttribute("canNull", gCanNull);
            oNode.setAttribute("minT", gMinT);
            oNode.setAttribute("minV", gMinV);
            oNode.setAttribute("maxT", gMaxT);
            oNode.setAttribute("maxV", gMaxV);

            if ($G('isReadOnly').checked) {
                oNode.setAttribute("readonly", "readonly");
            } else {
                oNode.removeAttribute("readonly");
            }
            oNode.setAttribute("readOnlyType", readOnlyType);
            oNode.setAttribute("tip", gTip);
            delete UE.plugins[thePlugins].editdom;
        }
    };
</script>
</body>
</html>